use derivative::Derivative;
use serde::{Deserialize, Serialize};

#[rbatis::crud_table(table_name:"files")]
#[derive(Serialize, Deserialize, Clone, Derivative, Debug)]
#[derivative(Default)]
pub struct FileDBO {
  pub id: String,
  pub snapshot_at: Option<String>,
  pub file_name: String,
  pub file_mode: Option<String>,
  pub file_owner: Option<String>,
  pub file_group: Option<String>,
  pub file_size: u32,
  pub title: Option<String>,
  pub description: Option<String>,
  pub content: Option<String>,
  pub referer_url: Option<String>,
  pub created_at: i64,
  pub updated_at: i64,
  pub status: Option<String>,
  pub folder_id: String,
}

#[rbatis::crud_table(table_name:"files")]
#[derive(Serialize, Deserialize, Clone, Derivative, Debug)]
#[derivative(Default)]
pub struct NewFileDBO {
  pub id: String,
  pub file_name: String,
  pub title: Option<String>,
  pub description: Option<String>,
  pub referer_url: Option<String>,
  pub folder_id: String,
}

#[rbatis::crud_table(table_name:"files")]
#[derive(Serialize, Deserialize, Clone, Derivative, Debug)]
#[derivative(Default)]
pub struct UpdateFileDBO {
  pub file_name: Option<String>,
  pub title: Option<String>,
  pub description: Option<String>,
  pub referer_url: Option<String>,
  pub content: Option<String>,
  pub folder_id: Option<String>,
  pub status: Option<String>,
}

#[rbatis::crud_table(table_name:"folders")]
#[derive(Serialize, Deserialize, Clone, Derivative, Debug)]
#[derivative(Default)]
pub struct FolderDBO {
  pub id: String,
  pub folder_name: String,
  pub snapshot_at: Option<String>,
  pub seq: Option<u32>,
  pub title: Option<String>,
  pub description: Option<String>,
  pub referer_url: Option<String>,
  pub ancestry: Option<String>,

  pub created_at: i64,
  pub updated_at: i64,
  pub status: Option<String>,
  pub pid: Option<String>,
}

#[rbatis::crud_table(table_name:"folders")]
#[derive(Serialize, Deserialize, Clone, Derivative, Debug)]
#[derivative(Default)]
pub struct NewFolderDBO {
  pub id: String,
  pub folder_name: String,
  pub title: Option<String>,
  pub description: Option<String>,
  pub referer_url: Option<String>,
  pub pid: String,
}

#[rbatis::crud_table(table_name:"folders")]
#[derive(Serialize, Deserialize, Clone, Derivative, Debug)]
#[derivative(Default)]
pub struct UpdateFolderDBO {
  pub folder_name: Option<String>,
  pub title: Option<String>,
  pub description: Option<String>,
  pub referer_url: Option<String>,
  pub pid: Option<String>,
  pub status:Option<String>,
}



#[rbatis::crud_table(table_name:"editors")]
#[derive(Serialize, Deserialize, Clone, Derivative, Debug)]
#[derivative(Default)]
pub struct EditorDBO {
  pub id: String,
  pub snapshot_at: Option<String>,

  pub title: Option<String>,

  pub created_at: i64,
  pub updated_at: i64,
  pub status: Option<String>,
}


#[rbatis::crud_table(table_name:"editors")]
#[derive(Serialize, Deserialize, Clone, Derivative, Debug)]
#[derivative(Default)]
pub struct NewEditorDBO {
  pub id: String,
  pub title: Option<String>,
  pub status: Option<String>,
}

#[rbatis::crud_table(table_name:"editors")]
#[derive(Serialize, Deserialize, Clone, Derivative, Debug)]
#[derivative(Default)]
pub struct UpdateEditorDBO {
  pub title: Option<String>,
  pub status: Option<String>,
}
